<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="nfk" prefix="nfk"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="../common.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新家庭在线CRM-编辑角色</title>

	<style type="text/css">
		body {
			text-align: center;
		}
		
		body,input {font-size: 12px;}
		input {border: 1px solid #cccccc;}		
		div input {margin-top: 4px;}
		
		.fl {float: left;}
		.fr {float: right;}
		
		.register {
			width: 600px;
			height: 600px;
			border: 1px solid #cccccc;
			text-align: center;
			margin-left: auto;
			margin-right: auto;
			padding-top: 30px;
			padding-bottom: 30px;
		}
		.register .item {
			width:410px;
			height: 30px;
			margin-left: auto;
			margin-right: auto;
		}
		.register .item .item_key {
			width: 160px;
			height: 30px;
			padding-left: 4px;
			padding-right: 4px;
			line-height: 30px;
			margin-left: auto;
			margin-right: auto;
			text-align: right;
		}
		.register .item .item_value {
			width: 200px;
			height: 30px;
			padding-left: 4px;
			padding-right: 4px;
			line-height: 30px;
			margin-left: auto;
			margin-right: auto;
			text-align: left;
		}
	</style>
	
	<script type="text/javascript">
		function TranOption(Obj1,Obj2)
		{  
		    var show = true;
		    for(var i=0;i<Obj1.options.length;i++)
		    {
		        if(Obj1.options[i].selected == true)
		        {
		            Obj2.options.add(new Option(Obj1.options[i].text,Obj1.options[i].value));
		            Obj1.remove(i);
		            i=i-1;
		            show = false;
		        }
		    }
		    if(show)
		    {
		        alert("请选择要移动的项！");
		    }
		}


		function submit_f() {
			var objsrc = document.getElementById("fromActionsParam");
			var objdest = document.getElementById("actionsParam");
			for(var i=0;i<objdest.options.length;i++)
		    {
		        objdest.options[i].selected = true;
		    }
		    return true;
		}
		
	</script>

</head>
<body>

	<div class="register">
		<s:form action="editRole" namespace="/security" method="post" onsubmit="return submit_f();">
		
			<div class="item">
				<div class="item_key fl">
					角色代码:
				</div>
				<div class="item_value fl">
					<input type="text" id="roleParam.roleId" name="roleParam.roleId" value="${roleParam.roleId }"/>
				</div>
			</div>
			<div class="item">
				<div class="item_key fl">
					描述:
				</div>
				<div class="item_value fl">
					<input type="text" id="roleParam.roleName" name="roleParam.roleName" value="${roleParam.roleName }"/>
				</div>
			</div>
			<div class="item" style="height: 200px">
				<div class="item_key fl">
					动作:
				</div>
				
					<table>
						<tr>
							<td height="60">
								<select style="border:1px solid #cccccc;height:200px;width:80px;" multiple="multiple" id="fromActionsParam" name="fromActionsParam">
									<s:iterator value="fromActionsParam" id="fap">
										<option value="${fap.actionId }">${fap.actionName }</option>
									</s:iterator>
								</select>
							</td>
							<td>
								<input type="button" value="添加" onclick="javascript:TranOption(fromActionsParam,actionsParam)">
								<br/>
								<input type="button" value="移除" onclick="javascript:TranOption(actionsParam,fromActionsParam)">
							</td>
							<td height="60">
								<select style="border:1px solid #cccccc;height:200px;width:80px;" multiple="multiple" id="actionsParam" name="actionsParam">
									<s:iterator value="roleParam.actions" id="ra">
										<option value="${ra.actionId }">${ra.actionName }</option>
									</s:iterator>
								</select>
							</td>
						</tr>
					</table>
				
			</div>
			<br/>
			<div class="item">
				<div class="item_key fl">
					
				</div>
				<div class="item_value fl">
					<input type="submit" value="保存"/>
				</div>
			
			</div>
			
		</s:form>
		<br/>
		<span style="color:#ff0000">${returnValue }</span>
	</div>

	
	
</body>
</html>